package com.jinxin.platform.cdqzsqacs.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @author : zhangpeng
 * @date : 2021-05-14 09:25:58
 **/
@Configuration
public class CdqzsqRestTemplateConfig {

    @Bean(name = "cdqzsqRestTemplate")
    public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
        return new RestTemplate(factory);
    }

    @Bean
    @Primary
    public ClientHttpRequestFactory ClientHttpRequestFactory() {
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        factory.setReadTimeout(8000);// 设置读取超时，单位毫秒
        factory.setConnectTimeout(10000);// 设置连接超时，单位毫秒
        return factory;
    }

}
